package com.kch.soundgame.objects;

import org.andengine.entity.sprite.AnimatedSprite;
import org.andengine.entity.sprite.Sprite;

import com.badlogic.gdx.physics.box2d.Body;

public class GameObject {
	private Body body;
	private Sprite sprite;
	private boolean animated = false;

	public GameObject(Sprite sprite, Body body, Object objectKey) {
		this.sprite = sprite;
		this.body = body;
		if (sprite.getClass().isInstance(AnimatedSprite.class)) {
			animated = true;
			((AnimatedSprite) sprite).animate(100);
		}
		this.body.setUserData(objectKey);
	}

	public Body getBody() {
		return body;
	}

	public Sprite getSprite() {
		return sprite;
	}

	public void animate(long[] durations) {
		if (animated) {
			((AnimatedSprite) sprite).animate(durations);
		}
	}
}
